using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;

public class LightController : MonoBehaviour
{
    public Image map;
    public GameObject light;
    private PlayableDirector lightDirector;

    private bool turnToDay;
    private bool isOpen = true;

    private void Awake()
    {
        lightDirector = light.GetComponent<PlayableDirector>();
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            turnToDay = true;
            Debug.Log("baitian");
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(1) && turnToDay)
        {
            lightDirector.Play();
            AudioManager.Instance.AudioSource.PlayDelayed(6f);
            turnToDay = false;
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            isOpen = !isOpen;
            map.gameObject.SetActive(isOpen);
        }
    }
}
